<?php
class smarty_ext_shop_cart {

	function smarty_ext_shop_cart() {
		global $setupdata, $mysqlclass, $shop_cartclass;
		$this->setupdata=$setupdata;
		$this->mysqlclass=$mysqlclass;
		$this->shop_cartclass=$shop_cartclass;
	}

	function get_all_source_types(){
		return $this->shop_cartclass->get_all_source_types();
	}
	
	function get_all_orders(){
		return $this->shop_cartclass->get_all_orders();
	}

	function get_all_orders_by_client_id($params){
		if ((isset($params['client_id']) && (strlen($params['client_id']) > 0))){
			$all_orders = $this->shop_cartclass->get_all_orders();
      foreach($all_orders as $key=>$el){
				if ($params['client_id'] != $el['client_id']) unset($all_orders[$key]);
			}
			return $all_orders;
		} else return array();
	}
	
	function clear_cart($params){
		if (!$params['card_id']) $cart_id = session_id();
		else $cart_id = $params['card_id'];
		if (!$params['card_group']) return $this->shop_cartclass->ClearCart($cart_id);
		else return $this->shop_cartclass->ClearCart($cart_id, $params['card_group']);
	}
	
	function get_order_data($params){
		if ((isset($params['order_id']) && (strlen($params['order_id']) > 0))){
			return $this->shop_cartclass->get_order_data($params['order_id']);
		}
	}
	
	function get_cart($params){
		if (!isset($params['cart_id'])) $cart_id = session_id();
		else $cart_id = $params['cart_id'];
		if (!isset($params['cart_group'])) return $this->shop_cartclass->GetCart($cart_id, 0, $_SESSION['lang']);
		else return $this->shop_cartclass->GetCart($cart_id, $params['cart_group'], $_SESSION['lang']);
	}
	
	function get_cart_groups_by_user($params){
		if (!isset($params['user_id'])) $user_id = session_id();
		else $user_id = $params['user_id'];
		return $this->shop_cartclass->GetCartGroups($user_id);
	}
	
	function get_stats(){
		return $this->shop_cartclass->get_statistics();
	}
		
	function get_last_used_group_cart_by_user($params){
		if (!isset($params['cart_id'])) $user_id = session_id();
		return $this->shop_cartclass->get_last_used_group_cart_by_user($user_id);
	}
		
	function get_mod_settings(){
		return $this->shop_cartclass->get_mod_settings();
	}
}
?>